n,m = map(int,input().split())
x = []
l1 = []
t1 = []
for i in range(n):
l, t = map(int, input().split())
l1.append(l)
l1.append(t)
j = l
while j < t:
j+=1
l1.append(j)
for k in range(1, m+1):
if k not in l1:
x.append(k)
count = len(x)
print(count)
print(*x)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define AM17 ios_base::sync_with_stdio(false),cin.tie(NULL);
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define lenSorts(s) sort(s.begin(), s.end(), [&] (const string &s, const string &t) { return s.size() < t.size();});
int dx4[4] = { -1, 0, 1, 0 };
int dy4[4] = { 0, 1, 0, -1 };
int dx8[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy8[] = {-1, +1, +0, +0, +1, -1, +1, -1};
string Dir = "URDL";
template <class T>
istream & operator>> (istream&is , vector<T> &v )
{
for (auto &i:v)
is>> i ;
return is ;
}
template <class T>
ostream & operator<< (ostream&os ,const vector<T> &v )
{
for (auto &i:v)
os << i << " " ;
os << '\n' ;
return os ;
}
//ll fastpow(ll a,ll p)
//{
// if(p==0)
// return 1ll;
//
// if(p&1)
// return ((a%MOD) * fastpow(a,p-1))%MOD;
// else
// {
// ll ret=(fastpow(a,p/2));
// return ((ret%MOD) * (ret%MOD))%MOD;
// }
//}
//
////ll w[N];
struct DSU{
// vector<ll>cost;
vector<int>parent;
vector<int>sz;
ll cost=0;
DSU(int n)
{
sz.resize(n+1);
parent.resize(n+1);
for (int i = 0; i <= n ; ++i) {
parent[i]=i;
sz[i]=1;
}
}
int find(int node)
{
if(parent[node]==node)
return parent[node];
return parent[node]= find(parent[node]);
}
bool add(int a,int b,int cost)
{
a= find(a);
b= find(b);
if(a==b)
return false;
if(sz[a]<sz[b])
{ swap(a,b);}
parent[b]=a;
sz[a]+=sz[b];
// parent[a]=parent[b];
this->cost+=cost;
return true;
}
bool all(int n)
{
int cnt=0;
for (int i = 1; i <=n ; ++i) {
cnt+=(parent[i]==i);
}
return cnt==1;
}
};
const int N=1005,M=1e5+10;
const int Mod=1e9+7;
vector<int>w,c;
int n,m;
int main()
{
int loop=1;
// cin>>loop;
while (loop--)
{
int m;
cin>>n>>m;
vector<int>v(m+1);
for (int i = 0; i < n; ++i) {
int x,y;
cin>>x>>y;
for (int j = x; j <=y ; ++j) {
v[j]=1;
}
}
vector<int>ans;
for (int i = 1; i <=m ; ++i) {
if(!v[i])
ans.push_back(i);
}
cout<<ans.size()<<endl<<ans;
}
}
1666F - Fancy Stack | 1354A - Alarm Clock |
1543B - Customising the Track | 1337A - Ichihime and Triangle |
1366A - Shovels and Swords | 919A - Supermarket |
630C - Lucky Numbers | 1208B - Uniqueness |
1384A - Common Prefixes | 371A - K-Periodic Array |
1542A - Odd Set | 1567B - MEXor Mixup |
669A - Little Artem and Presents | 691B - s-palindrome |
851A - Arpa and a research in Mexican wave | 811A - Vladik and Courtesy |
1006B - Polycarp's Practice | 1422A - Fence |
21D - Traveling Graph | 1559B - Mocha and Red and Blue |
1579C - Ticks | 268B - Buttons |
898A - Rounding | 1372B - Omkar and Last Class of Math |
1025D - Recovering BST | 439A - Devu the Singer and Churu the Joker |
1323A - Even Subset Sum Problem | 1095A - Repeating Cipher |
630F - Selection of Personnel | 630K - Indivisibility |